package com.usian.article.service.impl;

import com.usian.article.mapper.ApArticleConfigMapper;
import com.usian.article.mapper.ApArticleContentMapper;
import com.usian.article.mapper.ApArticleMapper;
import com.usian.article.service.ApArticleService;
import com.usian.model.article.pojo.ApArticle;
import com.usian.model.article.pojo.ApArticleConfig;
import com.usian.model.article.pojo.ApArticleContent;
import com.usian.model.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ApArticleServiceImpl extends BaseServiceImpl<ApArticleMapper, ApArticle> implements ApArticleService {

    @Autowired
    private ApArticleContentMapper contentMapper;
    @Autowired
    private ApArticleConfigMapper configMapper;


    @Override
    public ApArticle saveArticle(ApArticle apArticle) {
        if (apArticle==null)return null;
        save(apArticle);
        return apArticle;
    }

    @Override
    public ApArticleConfig saveArticleConfig(ApArticleConfig config) {
        if (config==null || config.getArticleId()==null)return null;
        contentMapper.insert(config);
        return config;
    }

    @Override
    public ApArticleContent saveArticleContent(ApArticleContent content) {
        if (content==null || content.getArticleId()==null)return null;
        contentMapper.insert(content);
        return content;
    }
}
